<?php

/**
 * City filter form base class.
 *
 * @package    symfony
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseCityFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'code'             => new sfWidgetFormFilterInput(),
      'iso'              => new sfWidgetFormFilterInput(),
      'name'             => new sfWidgetFormFilterInput(),
      'rawName'          => new sfWidgetFormFilterInput(),
      'longitude_radian' => new sfWidgetFormFilterInput(),
      'latitude_radian'  => new sfWidgetFormFilterInput(),
      'mainTown_id'      => new sfWidgetFormFilterInput(),
      'department_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Department'), 'add_empty' => true)),
      'region_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Region'), 'add_empty' => true)),
      'country_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'code'             => new sfValidatorPass(array('required' => false)),
      'iso'              => new sfValidatorPass(array('required' => false)),
      'name'             => new sfValidatorPass(array('required' => false)),
      'rawName'          => new sfValidatorPass(array('required' => false)),
      'longitude_radian' => new sfValidatorPass(array('required' => false)),
      'latitude_radian'  => new sfValidatorPass(array('required' => false)),
      'mainTown_id'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'department_id'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Department'), 'column' => 'id')),
      'region_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Region'), 'column' => 'id')),
      'country_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Country'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('city_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'City';
  }

  public function getFields()
  {
    return array(
      'id'               => 'Number',
      'code'             => 'Text',
      'iso'              => 'Text',
      'name'             => 'Text',
      'rawName'          => 'Text',
      'longitude_radian' => 'Text',
      'latitude_radian'  => 'Text',
      'mainTown_id'      => 'Number',
      'department_id'    => 'ForeignKey',
      'region_id'        => 'ForeignKey',
      'country_id'       => 'ForeignKey',
    );
  }
}
